/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tramite.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.tramite.be.EnumTipoTramite;
import org.cip.esymons.tramite.be.Tramite;

/**
 *
 * @author Freddy Infantes
 */
public class TramiteDelegate {
    private TramiteFacadeLocal local;



    public TramiteDelegate() {
        local= lookupTramiteFacade();
    }
    
    public void create(Tramite tramite)
    {
        local.create(tramite);
    }
    
    public void edit(Tramite tramite)
    {
        local.edit(tramite);
    }

    public void remove(Tramite tramite)
    {
        local.remove(tramite);
    }

    public Tramite find(Object id)
    {
        return local.find(id);
    }

    public List<Tramite> findAll()
    {
        return local.findAll();
    }

    public List<Tramite> listarXTipo(EnumTipoTramite tipo){
        return local.listarXTipo(tipo);
    }

    public Tramite buscar(String desc){
        return local.buscar(desc);
    }

    public List<Tramite> buscarPorNombre(String desc){
        return local.buscarPorNombre(desc);
    }

     public List<Tramite> paginadorTramite(int cantidad, int posicion, String nom){
        return local.paginadorTramite(cantidad, posicion, nom);
    }

    public int contarPaginadorTramite(String nom){
        return local.contarPaginadorTramite(nom);
    }

    private TramiteFacadeLocal lookupTramiteFacade() {
        try {
            Context c = new InitialContext();
            return (TramiteFacadeLocal) c.lookup("java:comp/env/TramiteFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }



}
